package com.jzhao.jpre.model;

import java.util.List;
import org.springframework.dao.DataAccessException;

import com.jzhao.jpre.base.Assembler;
import com.jzhao.jpre.model.CustInfo;
import com.jzhao.jpre.model.dao.CustInfoDao;

public class TestCustInfo {
	public static void main(String[] args) {
		Assembler.start();
		CustInfoDao custInfoDao = (CustInfoDao) Assembler
				.getInstance("custInfoDao");
		String SysCustInfStat = "";
		try {
			CustInfo custInfo = new CustInfo();
			List custInfos = custInfoDao.queryCustInfo("02810004",
					"9003011600000702", "028004", "00610021");
			if (custInfos.size()== 0) {
				custInfo.setDebitMer("02810004");
				custInfo.setDebitAcct("9003011600000702");
				custInfo.setBusiType("028004");
				custInfo.setCreditAcct("00610021");
				custInfo.setStatus("0");
				custInfo.setApplyDay("20080108");
				custInfoDao.insert(custInfo);
				SysCustInfStat = "1";
			} else {
				custInfo =(CustInfo) custInfos.get(0);
				if (custInfo.getStatus().equals("0"))
					SysCustInfStat = "0";
				if (custInfo.getStatus().equals("1"))
					SysCustInfStat = "1";
			}
			System.out.println(SysCustInfStat);
			/*Integer infoCount = custInfoDao.queryInfoCount("02810004",
					"9003011600000702", "028004", "00610021");
			int count = ((Integer)infoCount).intValue();
			if(count == 0){
				custInfo.setDebitMer("02810004");
				custInfo.setDebitAcct("9003011600000702");
				custInfo.setBusiType("028004");
				custInfo.setCreditAcct("00610021");
				custInfo.setStatus("0");
				custInfo.setApplyDay("20080108");
				custInfoDao.insert(custInfo);
			}
			*/
			custInfoDao.infoBindApply("02810004",
					"9003011600000702", "028004", "00610021","20080506");
			
			custInfoDao.cancleInfoBind("02810004",
					"9003011600000702", "028004", "00610021");
			
			//custInfoDao.cancleAllInfoBind("02810004", "9003011600000702");
			System.out.println("Test ok!");
			
		} catch (DataAccessException dae) {
			dae.getMessage();
			System.out.println(dae.getMessage());
		}	
	}
}
